package com.travel.rabbit.controller.admin;

import com.travel.rabbit.entity.GoodsCategory;
import com.travel.rabbit.service.GoodsCategoryService;
import com.travel.rabbit.entity.Result;
import com.travel.rabbit.dto.GoodsCategoryDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (GoodsCategory)表控制层
 *
 * @author makejava
 * @since 2021-12-31 15:58:35
 */
@Api(tags = "商品分类模块")
@RestController
@RequestMapping("goodsCategory")
public class GoodsCategoryController {
    /**
     * 服务对象
     */
    @Resource
    private GoodsCategoryService categoryService;

    @ApiOperation(value = "添加分类",tags = {"商品分类模块"})
    @PostMapping("/add")
    public Result add(@RequestBody GoodsCategoryDTO categoryVO){
       return categoryService.add(categoryVO);
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("/queryById")
    public Result<GoodsCategory> queryById(Integer id) {
        return Result.success(this.categoryService.queryById(id));
    }

}